<script type="text/javascript" language="javascript">
    (function($) {
        /*whatever jQuery stuff*/
        $(function(){
            jQuery.validator.addMethod("intrend_required", function(value, element, param) {
                var returnVal = true;
                $("select[name='intrend_module[]'],input[name='intrend_id[]']").each(function(){
                	if($(this).val() == '') returnVal = false
                });
				return returnVal;
           	}, jQuery.validator.messages.intrend_required);
           	        					
            $("#Form").validate({
				ignore: "",
                rules: {
					"intrend_module[]": {
						intrend_required:true
					}
                },
                showErrors: function(errorMap, errorList){
                    var messages='';
                    for (var i = 0; i < errorList.length; i++) {					
                        messages += '- '+errorList[i].message+'\n';
                    }
                    if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
                    //this.defaultShowErrors();
                } ,
                submitHandler: function(e){
					$('.ajax-loading',e).css('visibility','visible');
					//Send Form
					document.forms["Form"].submit();
                },
                onfocusout: false,
                onkeyup: false,
				onclick: false,					
                messages: {
					"intrend_module[]": {
						intrend_required : "<?php echo lang('home_intrend');?>"
					}
                }
            });
        });
    })(jQuery);
		/*Show Search*/
		var intrend_on_search='';
		function showSearch(e)
		{
			$(e).parent().find('.search_tools2').remove();
			$(e).parent().find('input').val('');
			switch(e.value){
				case 'Album':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_album";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Movie':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_movie";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Song':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_song";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Video':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_video";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Gallery':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_gallery";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Fashion':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_fashion";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'News':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_news";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Calendar':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_calendar";?>" class="tools magnify search_tools2"></a>');
				break;
				case 'Playlist':
					$(e).parent().append('<a href="<?php echo base_url()."intrend/content_management/search_playlist";?>" class="tools magnify search_tools2"></a>');
				break;																												
			}
			$('.search_tools2').colorbox({
				onLoad:function(){ intrend_on_search = $(this).parent(); },
				onClosed:function(){ intrend_on_search = "";},
				iframe:true, 
				innerWidth:300, 
				innerHeight:600, 
				right:0, 
				opacity:0.4
			});
		}
		/*Add/Remove List*/
		function addRemoveList(unique,id,name)
		{
			intrend_on_search.find('input[name="intrend_id[]"]').val(''+id+'');
		}		
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">	
            <div class="inside">			
				<form id="Form" method="post" action="" name="Form">
					<table border="0" cellspacing="0" cellpadding="0" class="form-table">
						<tbody>	
						<tr>
							<th scope="row"><?php echo lang('home_intrend');?></th>
							<td>
								<div style="padding:3px 0;">
									<select name="intrend_module[]" onchange="javascript:showSearch(this);">
										<option value=""><?php echo lang('select_option');?></option>
										<option value="Album" <?php echo ($dataResult[0]->module == "Album" ? "selected":"");?>>Album ID:</option>
										<option value="Song" <?php echo ($dataResult[0]->module == "Song" ? "selected":"");?>>Song ID:</option>
									</select>
									<input type="text" name="intrend_id[]" class="small-text" readonly="readonly" value="<?php echo $dataResult[0]->value;?>"/>
								</div>
								<div style="padding:3px 0;">
									<select name="intrend_module[]" onchange="javascript:showSearch(this);">
										<option value=""><?php echo lang('select_option');?></option>
										<option value="Movie" <?php echo ($dataResult[1]->module == "Movie" ? "selected":"");?>>Movie ID:</option>
										<option value="Video" <?php echo ($dataResult[1]->module == "Video" ? "selected":"");?>>Video ID:</option>
										<option value="News" <?php echo ($dataResult[1]->module == "News" ? "selected":"");?>>News ID:</option>
										<option value="Gallery" <?php echo ($dataResult[1]->module == "Gallery" ? "selected":"");?>>Gallery ID:</option>
										<option value="Calendar" <?php echo ($dataResult[1]->module == "Calendar" ? "selected":"");?>>Calendar ID:</option>
										<option value="Fashion" <?php echo ($dataResult[1]->module == "Fashion" ? "selected":"");?>>Fashion ID:</option>
										<option value="Playlist" <?php echo ($dataResult[1]->module == "Playlist" ? "selected":"");?>>Playlist ID:</option>
									</select>
									<input type="text" name="intrend_id[]" class="small-text" readonly="readonly" value="<?php echo $dataResult[1]->value;?>"/>
								</div>
								<div style="padding:3px 0;">
									<select name="intrend_module[]" onchange="javascript:showSearch(this);">
										<option value=""><?php echo lang('select_option');?></option>
										<option value="Movie" <?php echo ($dataResult[2]->module == "Movie" ? "selected":"");?>>Movie ID:</option>
										<option value="Video" <?php echo ($dataResult[2]->module == "Video" ? "selected":"");?>>Video ID:</option>
										<option value="News" <?php echo ($dataResult[2]->module == "News" ? "selected":"");?>>News ID:</option>
										<option value="Gallery" <?php echo ($dataResult[2]->module == "Gallery" ? "selected":"");?>>Gallery ID:</option>
										<option value="Calendar" <?php echo ($dataResult[2]->module == "Calendar" ? "selected":"");?>>Calendar ID:</option>
										<option value="Fashion" <?php echo ($dataResult[2]->module == "Fashion" ? "selected":"");?>>Fashion ID:</option>
										<option value="Playlist" <?php echo ($dataResult[2]->module == "Playlist" ? "selected":"");?>>Playlist ID:</option>
									</select>
									<input type="text" name="intrend_id[]" class="small-text" readonly="readonly" value="<?php echo $dataResult[2]->value;?>"/>
								</div>
								<div style="padding:3px 0;">
									<select name="intrend_module[]" onchange="javascript:showSearch(this);">
										<option value=""><?php echo lang('select_option');?></option>
										<option value="Movie" <?php echo ($dataResult[3]->module == "Movie" ? "selected":"");?>>Movie ID:</option>
										<option value="Video" <?php echo ($dataResult[3]->module == "Video" ? "selected":"");?>>Video ID:</option>
										<option value="News" <?php echo ($dataResult[3]->module == "News" ? "selected":"");?>>News ID:</option>
										<option value="Gallery" <?php echo ($dataResult[3]->module == "Gallery" ? "selected":"");?>>Gallery ID:</option>
										<option value="Calendar" <?php echo ($dataResult[3]->module == "Calendar" ? "selected":"");?>>Calendar ID:</option>
										<option value="Fashion" <?php echo ($dataResult[3]->module == "Fashion" ? "selected":"");?>>Fashion ID:</option>
										<option value="Playlist" <?php echo ($dataResult[3]->module == "Playlist" ? "selected":"");?>>Playlist ID:</option>
									</select>
									<input type="text" name="intrend_id[]" class="small-text" readonly="readonly" value="<?php echo $dataResult[3]->value;?>"/>
								</div>
								<div style="padding:3px 0;">
									<select name="intrend_module[]" onchange="javascript:showSearch(this);">
										<option value=""><?php echo lang('select_option');?></option>
										<option value="Movie" <?php echo ($dataResult[4]->module == "Movie" ? "selected":"");?>>Movie ID:</option>
										<option value="Video" <?php echo ($dataResult[4]->module == "Video" ? "selected":"");?>>Video ID:</option>
										<option value="News" <?php echo ($dataResult[4]->module == "News" ? "selected":"");?>>News ID:</option>
										<option value="Gallery" <?php echo ($dataResult[4]->module == "Gallery" ? "selected":"");?>>Gallery ID:</option>
										<option value="Calendar" <?php echo ($dataResult[4]->module == "Calendar" ? "selected":"");?>>Calendar ID:</option>
										<option value="Fashion" <?php echo ($dataResult[4]->module == "Fashion" ? "selected":"");?>>Fashion ID:</option>
										<option value="Playlist" <?php echo ($dataResult[4]->module == "Playlist" ? "selected":"");?>>Playlist ID:</option>
									</select>
									<input type="text" name="intrend_id[]" class="small-text" readonly="readonly" value="<?php echo $dataResult[4]->value;?>"/>
								</div>
							</td>
						</tr>														
						<tr>
							<th scope="row">&nbsp;</th>
							<td><p class="submit"><input type="submit" value="<?php echo lang('button_update');?>" class="button-primary" />&nbsp;<img alt="" class="ajax-loading" src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" /></p></td>
						</tr>								
						</tbody>
					</table>
					<div class="tablenav bottom"></div>
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->